package org.lee.normal.delegate;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;

public class LoggingMemoryDatabase extends MemoryDatabase {
    private class LoadMethodSuperCall implements Callable {
        private final String info;

        private LoadMethodSuperCall(String info) {
            this.info = info;
        }

        @Override
        public Object call() throws Exception {
            return LoggingMemoryDatabase.super.load(info);
        }
    }

    @Override
    public List<String> load(String info) {
        try {
            return LoggerInterceptor.log(new LoadMethodSuperCall(info));
        } catch (Exception e) {
            e.printStackTrace();
            return new ArrayList<>();
        }
    }
}
